var lotteryIds=sessionStorage.getItem("viewdetail")
gamedetails()
function gamedetails() {
    $.ajax({
        url: 'https://'+ window.location.host +'/api/admin/apromotion/lotteryDraw/getLotteryDrawDetail',
        cache: false, //禁用缓存
        dataType: "json",
        type:"post",
        data:{
            "lotteryId":lotteryIds,
        },
        success: function (data) {
        console.log(data)
            if(data.data.lotteryDrawBase!=null){
                $("#lotteryAfterName").text(data.data.lotteryDrawBase.lotteryAfterName)
                $("#lotteryBeforeName").text(data.data.lotteryDrawBase.lotteryBeforeName)
                $("#beginTime").text(data.data.lotteryDrawBase.startTime+'~'+data.data.lotteryDrawBase.endTime)
                $("#platform").text("普通平台")
                $("#customerType").text("普通会员   认证会员")
                var abnormalType = "";
                if(data.data.lotteryDrawBase.source.match('10')&&data.data.lotteryDrawBase.source.match('20')&&data.data.lotteryDrawBase.source.match('30')){
                    abnormalType="不限"
                }else {

                    var abnormalTypeArr = [];
                    var rowArr = data.data.lotteryDrawBase.source.split(',');
                    function getAbnormalType(typeCode) {
                        switch(typeCode) {
                            case "10":
                                return "PC";
                                break;
                            case "20":
                                return "APP";
                                break;
                            case "30":
                                return "H5";
                                break;
                        }
                    }
                    for(var i = 0; i < rowArr.length; i++) {
                        abnormalTypeArr.push(getAbnormalType(rowArr[i]));
                    }
                    for(var j = 0; j < abnormalTypeArr.length; j++) {
                        if(j < abnormalTypeArr.length - 1) {
                            abnormalType += abnormalTypeArr[j] + " ";
                        } else {
                            abnormalType += abnormalTypeArr[j] + "";
                        }
                    }
                }
                $("#source").text(abnormalType)

                $("#pcUrl").val(data.data.lotteryDrawBase.pcUrl)
                $("#appUrl").val(data.data.lotteryDrawBase.appUrl)
                $("#h5Url").val(data.data.lotteryDrawBase.h5Url)
                if(data.data.lotteryDrawBase.joinRequire==10){
                    $("#joinRequire").text("免费参加")
                    $("#joinRequire30").css({
                        display: "none"
                    });
                    $("#joinRequire40").css({
                        display: "none"
                    });
                    $("#joinRequire50").css({
                        display: "none"
                    });
                    $("#joinRequire60").css({
                        display: "none"
                    });
                }else  if(data.data.lotteryDrawBase.joinRequire==20){
                    $("#joinRequire").text("新用户注册")
                    $("#joinRequire30").css({
                        display: "none"
                    });
                    $("#joinRequire40").css({
                        display: "none"
                    });
                    $("#joinRequire50").css({
                        display: "none"
                    });
                    $("#joinRequire60").css({
                        display: "none"
                    });
                }else  if(data.data.lotteryDrawBase.joinRequire==30){
                    $("#joinRequire").text("消耗积分")
                    $("#joinRequire30").css({
                        display: "inline"
                    });
                    $("#joinRequire40").css({
                        display: "none"
                    });
                    $("#joinRequire50").css({
                        display: "none"
                    });
                    $("#joinRequire60").css({
                        display: "none"
                    });
                    $(".joinRequires").text(data.data.lotteryDrawBase.joinConsume)
                }else  if(data.data.lotteryDrawBase.joinRequire==40){
                    $("#joinRequire").text("累计订单数量")
                    $("#joinRequire40").css({
                        display: "inline"
                    });
                    $("#joinRequire50").css({
                        display: "none"
                    });
                    $("#joinRequire30").css({
                        display: "none"
                    });
                    $("#joinRequire60").css({
                        display: "none"
                    });
                    $(".joinRequires").text(data.data.lotteryDrawBase.joinConsume)
                }else  if(data.data.lotteryDrawBase.joinRequire==50){
                    $("#joinRequire").text("累计满金额")
                    $("#joinRequire50").css({
                        display: "inline"
                    });
                    $("#joinRequire40").css({
                        display: "none"
                    });
                    $("#joinRequire30").css({
                        display: "none"
                    });
                    $("#joinRequire60").css({
                        display: "none"
                    });
                    $(".joinRequires").text(data.data.lotteryDrawBase.joinConsume)
                }
                else  if(data.data.lotteryDrawBase.joinRequire==60){
                    $("#joinRequire").text("单笔订单满金额")
                    $("#joinRequire60").css({
                        display: "inline"
                    });
                    $("#joinRequire40").css({
                        display: "none"
                    });
                    $("#joinRequire30").css({
                        display: "none"
                    });
                    $("#joinRequire50").css({
                        display: "none"
                    });
                    $(".joinRequires").text(data.data.lotteryDrawBase.joinConsume)
                }
                if(data.data.lotteryDrawBase.limitWay==10){
                    $("#limitWay").text("固定次数")
                    $("#limitWay10").css({
                        display: "inline"
                    });
                    $("#limitWay20").css({
                        display: "none"
                    });
                    $(".limitWays").text(data.data.lotteryDrawBase.limitNum)
                }else {
                    $("#limitWay").text("周期次数")
                    $("#limitWay10").css({
                        display: "none"
                    });
                    $("#limitWay20").css({
                        display: "inline"
                    });
                    $(".limitWays").text(data.data.lotteryDrawBase.limitNum)
                }
                $("#virtualNameDisplay").text("显示")
                $("#rule").html(data.data.lotteryDrawBase.rule)
                if(data.data.prizeList!=null){
                    xuanran(data.data.prizeList)
                }

            }
        },
        error: function () {
            $.Huimodalalert('失败！',2000);
        }
    });
}

function xuanran(val) {
    //渲染表格
    var coner=9//当前列表条数
    var listHtml=''
    for(var i=0; i<val.length; i++){
        var jnamne=""
        if(val[i].prizeTag==20||val[i].prizeTag==30){
            jnamne='<span>'+val[i].prizeName+'</span><br>ID:<span>'+val[i].couponSendCode+'</span>'
        }else {
            jnamne='<span>'+val[i].prizeName+'</span>'
        }
        listHtml+=''
            +'<tr id="productList">'
            +'<td class="nus">'+val[i].orderNumber+'</td>'
            +'<td class="rfqg_td1">'
            +'<span>'+jnamne+'</span>'
            +'</td>'
            +'<td class="rfqg_td2">'
            +'<span>'+val[i].prizeDisplayName+'</span>'
            +'</td>'
            +'<td class="rfqg_td3">'
            +'<span>'+val[i].count+'</span>'
            +'</td>'
            +'<td class="rfqg_td4">'
            +'<span>'+val[i].winProbability+'</span>'
            +'</td>'
            +'</tr>'
        $('#shunlist').html(listHtml)

    }
}
//复制链接
function copyNewUrl(val) {
    var urlid=""
    if(val==1){
        urlid=document.getElementById("pcUrl");
    }else if(val==2){
        urlid=document.getElementById("appUrl");
    }else if(val==3){
        urlid=document.getElementById("h5Url");
    }
        var Url=urlid
    console.log(Url)
        Url.select(); // 选择对象
        document.execCommand("Copy"); // 执行浏览器复制命令
        layer.msg('复制成功！', {icon: 6,time:1000});

}